package org.bao.response;

import lombok.Data;

/**
 * 结果类
 * @author mohe
 * @date
 */
@Data
public class Response<T> {

    private T message;
    private Integer code;
    private boolean success;

    public Response(T message, Integer code, boolean success) {
        this.message = message;
        this.code = code;
        this.success = success;
    }


    public static <T> Response<T> success(T message) {
        return new Response<>(message,200,true);
    }

    public static Response success() {
        return new Response<>(null, 200, true);
    }

    public static <T> Response error(T message,Integer code) {
        return new Response<>(message, code, false);
    }

    public static Response error(ResponseEnum ex) {
        return error(ex.getMsg(),ex.getCode());
    }


}
